package com.example.spring_source_code.bean.post;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

@Component
@Primary
public class Bean01 {
    public static final Logger log = LoggerFactory.getLogger(Bean01.class);
    public Bean01() {
        log.info("构造");
    }

    @Resource
    public void resource(@Value("${JAVA_HOME}") String javaHome) {
        log.info("resource");
    }

    @Autowired
    public void autowired(@Value("${JAVA_HOME}") String javaHome) {
        log.info("autoWired");
    }

    @PreDestroy
    public void destroy() {
        log.info("销毁");
    }

    @PostConstruct
    public void init() {
        log.info("构造后");
    }

    private void initMethod() {
        System.out.println("init Method.....");
    }
}
